home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / oop_tp55.zip / LIST5_4.PAS < prev    next >
Pascal/Delphi Source File  |  1990-01-25  |  2KB  |  64 lines

  1. { Declarations from the interface section of Listing 3-1 }
  2.  
  3. DInput = object(Digital)
  4.             Setpoint  : real;
  5.             Reading   : real;
  6.             procedure Init( ATag : string;
  7.                             ASetpoint : real;
  8.                             AReading : real);
  9.             procedure PutReading( NewReading : real ); {should be virtual; }
  10.             procedure PutSetpoint( NewSetpoint : real );
  11.             end;
  12.  
  13. HiSwitch = object(DInput)
  14.            procedure PutReading( NewReading : real ); {should be virtual; }
  15.            end;
  16.  
  17. LoSwitch = object(DInput)
  18.            procedure PutReading( NewReading : real ); {should be virtual; }
  19.  
  20.            end;
  21.  
  22.  
  23. { Procedure definitions from the implementation section of Listing 3-1 }
  24.  
  25. procedure DInput.Init( ATag : string;
  26.                        ASetpoint : real;
  27.                        AReading : real);
  28. begin
  29.      Tag.Init( ATag );
  30.      DInput.PutSetpoint( ASetpoint );
  31.      PutReading( AReading );
  32. end;
  33.  
  34. procedure DInput.PutReading( NewReading : real );
  35. begin
  36.      writeln( 'If this prints, .PutReading should be virtual!' );
  37. end;
  38.  
  39. procedure LoSwitch.PutReading( NewReading : real );
  40. begin
  41.      Reading := NewReading;
  42.      if Reading <= Setpoint then
  43.         Status := true
  44.      else
  45.         Status := false;
  46. end;
  47.  
  48. {procedure HiSwitch.Init( ATag : string;
  49.             ASetpoint : real;
  50.             AReading : real); }  { DELETED! }
  51.  
  52. procedure HiSwitch.PutReading( NewReading : real );
  53. begin
  54.      Reading := NewReading;
  55.      if Reading >= Setpoint then
  56.         Status := true
  57.      else
  58.         Status := false;
  59. end;
  60.  
  61.  
  62. { Listing 5-4 }
  63.  
  64.